package com.vincent.kdp.adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.vincent.kdp.R;
import com.vincent.kdp.bean.MySeriesAdapterBean;
import com.vincent.kdp.bean.QualityBean;

import java.util.ArrayList;

/**
 * Created by jingjing on 2017/3/9.
 */

public class MySeriesGridViewAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<MySeriesAdapterBean.MySeriesData> data;
    private ArrayList<TextView> list=new ArrayList<>();
    public MySeriesGridViewAdapter(Context context,ArrayList<MySeriesAdapterBean.MySeriesData> data){
        this.context=context;
        this.data=data;
    }

    //删除选择条件
    public void removeMySeriesSelect(){
        for(int x=0;x<list.size();x++){
            list.get(x).setTextColor(Color.parseColor("#311d0f"));
            GradientDrawable draw=new GradientDrawable();
            draw.setStroke(1,Color.parseColor("#ececec"));
            draw.setColor(Color.parseColor("#ffffff"));
            list.get(x).setBackground(draw);
        }
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.tv_series,null);
            vh=new ViewHolder();
            vh.tv_series= (TextView) convertView.findViewById(R.id.tv_series);
            list.add(vh.tv_series);
            convertView.setTag(vh);
        }else{
            vh= (ViewHolder) convertView.getTag();
        }
        vh.tv_series.setText(data.get(position).getName());
        return convertView;
    }

    class ViewHolder{
        TextView tv_series;
    }
}
